const TestConfig = require('./test.config')
const DevConfig = require('./dev.config')
const ProdConfig = require('./prod.config')

const config = {
  test: TestConfig,
  dev: DevConfig,
  prod: ProdConfig
}

const get = function (env) {
  const key = env || process.env.NODE_ENV || 'dev'

  if (!config[key]) {
    throw new Error('未知的key: ' + key)
  }

  return config[key]
}

module.exports = get()
module.exports.get = get
